package com.yanfan.ccapi.controller;

import com.yanfan.ccapi.service.ICcapiFunctionMappingService;
import com.yanfan.ccapicode.dao.entity.FunctionMappingDO;
import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.core.page.TableDataInfo;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 产品功能属性映射Controller
 *
 * @author kerwincui
 * @date 2025-06-29
 */
@RestController
@RequestMapping("/ccapi/functionMapping")
@Api(tags = "产品功能属性映射")
public class CcapiFunctionMappingController extends BaseController {
    @Autowired
    private ICcapiFunctionMappingService ccapiFunctionMappingService;

    /**
     * 查询产品功能属性映射列表
     */
//@PreAuthorize("@ss.hasPermi('ccapi:functionMapping:list')")
    @GetMapping("/list")
    @ApiOperation("查询产品功能属性映射列表")
    public TableDataInfo list(FunctionMappingDO ccapiFunctionMapping) {
        startPage();
        List<FunctionMappingDO> list = ccapiFunctionMappingService.selectCcapiFunctionMappingList(ccapiFunctionMapping);
        return getDataTable(list);
    }

    /**
     * 导出产品功能属性映射列表
     */
    @ApiOperation("导出产品功能属性映射列表")
    //@PreAuthorize("@ss.hasPermi('ccapi:functionMapping:export')")
    @Log(title = "产品功能属性映射", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FunctionMappingDO ccapiFunctionMapping) {
        List<FunctionMappingDO> list = ccapiFunctionMappingService.selectCcapiFunctionMappingList(ccapiFunctionMapping);
        ExcelUtil<FunctionMappingDO> util = new ExcelUtil<FunctionMappingDO>(FunctionMappingDO.class);
        util.exportExcel(response, list, "产品功能属性映射数据");
    }

    /**
     * 获取产品功能属性映射详细信息
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:functionMapping:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取产品功能属性映射详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ccapiFunctionMappingService.selectCcapiFunctionMappingById(id));
    }

    /**
     * 新增产品功能属性映射
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:functionMapping:add')")
    @Log(title = "产品功能属性映射", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增产品功能属性映射")
    public AjaxResult add(@RequestBody FunctionMappingDO ccapiFunctionMapping) {
        return toAjax(ccapiFunctionMappingService.insertCcapiFunctionMapping(ccapiFunctionMapping));
    }

    /**
     * 修改产品功能属性映射
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:functionMapping:edit')")
    @Log(title = "产品功能属性映射", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改产品功能属性映射")
    public AjaxResult edit(@RequestBody FunctionMappingDO ccapiFunctionMapping) {
        return toAjax(ccapiFunctionMappingService.updateCcapiFunctionMapping(ccapiFunctionMapping));
    }

    /**
     * 删除产品功能属性映射
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:functionMapping:remove')")
    @Log(title = "产品功能属性映射", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除产品功能属性映射")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ccapiFunctionMappingService.deleteCcapiFunctionMappingByIds(ids));
    }
}
